﻿using System;
using System.Configuration;
using System.Drawing;
using System.Drawing.Printing;
using System.Windows.Forms;
using Billing.Utilities;

namespace Billing
{
    public partial class CakeDeliveryPrinter : Form
    {
        PaperSize psize;
        string cakeNo;
        string billNo;
        string amount;

        public CakeDeliveryPrinter(string cakeNo, string billNo, string amount)
        {
            InitializeComponent();
            this.cakeNo = cakeNo;
            this.billNo = billNo;
            this.amount = amount;
        }

        private void printDocument1_PrintPage(object sender, PrintPageEventArgs e)
        {
            e.PageSettings.PaperSize = psize;
            e.Graphics.DrawString("KS BAKERS", new Font(new FontFamily("Times New Roman"), 10, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, 100, 0);
            e.Graphics.DrawString(ConfigurationManager.AppSettings["ColonyName"], new Font(new FontFamily("Times New Roman"), 9, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, 15, 13);
            e.Graphics.DrawString(ConfigurationManager.AppSettings["TinNo"], new Font(new FontFamily("Times New Roman"), 9, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, 80, 26);
            e.Graphics.DrawString("Date : " + DateTime.Now.ToString("dd/MM/yy") + "  " + DateTime.Now.ToShortTimeString() + " Cashier : " + Storage.LoginUserName, new Font(new FontFamily("Times New Roman"), 9, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, 9, 45);

            e.Graphics.DrawString("Cake No : " + cakeNo, new Font(new FontFamily("Times New Roman"), 12, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, 8, 70);
            e.Graphics.DrawString("Bill No : " + billNo, new Font(new FontFamily("Times New Roman"), 12, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, 8, 100);
            e.Graphics.DrawString("Cake Balance Amount Paid : " + amount + " /-", new Font(new FontFamily("Times New Roman"), 12, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, 8, 130);

            //e.Graphics.DrawString("Date : " + DateTime.Now.ToString("dd/MM/yy") + "  " + DateTime.Now.ToShortTimeString() + "    Bill No:" + BillNo, new Font(new FontFamily("Times New Roman"), 9, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, 9, 45);
            //e.Graphics.DrawString("Cake Balance Amount : " + Amount, new Font(new FontFamily("Times New Roman"), 50, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, 100, 55);

            //int lineCounter = 75;
            //e.Graphics.DrawString("--------------------------------------------------------------", new Font(new FontFamily("Times New Roman"), 10, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, 10, lineCounter);
            //lineCounter += 15;

            //e.Graphics.DrawString("       " + ItemName + "        " + Qty, new Font(new FontFamily("Times New Roman"), 9, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, 10, lineCounter);

            //lineCounter += 20;
            e.Graphics.DrawString("Your order will take 5-10 minutes. Please wait...", new Font(new FontFamily("Times New Roman"), 9, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.Black, 30, 260);
            e.Graphics.RotateTransform(-30);
            e.Graphics.DrawString("CAKE BALANCE", new Font(new FontFamily("Times New Roman"), 25, System.Drawing.FontStyle.Regular), System.Drawing.Brushes.LightSlateGray, -80, 205);
            e.Graphics.ResetTransform();
        }

        private void printDocument1_QueryPageSettings(object sender, System.Drawing.Printing.QueryPageSettingsEventArgs e)
        {
            psize = new PaperSize("saurabh", 300, 300);
            e.PageSettings.PaperSize = psize;
        }
    }
}
